home *** CD-ROM | disk | FTP | other *** search
- /* Functions for the Amiga Intuition Windows system.
- Copyright (C) 1989, 1992, 1993, 1994 Free Software Foundation, Inc.
-
- This file is part of GNU Emacs.
-
- GNU Emacs is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GNU Emacs is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- /* Adapted from xnfs.c, 08/27/94 Carsten Heyl,
- some stuff moved from David Gays amiga_screen.c */
-
- #include <exec/types.h>
- #include <libraries/gadtools.h>
- #include <intuition/intuition.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/gadtools.h>
- #include <proto/intuition.h>
-
- #include "config.h"
- #include "lisp.h"
- #include "frame.h"
- #include "amiga.h"
-
- #ifdef USE_PROTOS
- #include "protos.h"
- #endif
-
- /* CHFIXME: change more functions to amiga version */
-
- /* Evaluate this expression to rebuild the section of syms_of_xfns
- that initializes and staticpros the symbols declared below. Note
- that Emacs 18 has a bug that keeps C-x C-e from being able to
- evaluate this expression.
-
- (progn
- ;; Accumulate a list of the symbols we want to initialize from the
- ;; declarations at the top of the file.
- (goto-char (point-min))
- (search-forward "/\*&&& symbols declared here &&&*\/\n")
- (let (symbol-list)
- (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
- (setq symbol-list
- (cons (buffer-substring (match-beginning 1) (match-end 1))
- symbol-list))
- (forward-line 1))
- (setq symbol-list (nreverse symbol-list))
- ;; Delete the section of syms_of_... where we initialize the symbols.
- (search-forward "\n /\*&&& init symbols here &&&*\/\n")
- (let ((start (point)))
- (while (looking-at "^ Q")
- (forward-line 2))
- (kill-region start (point)))
- ;; Write a new symbol initialization section.
- (while symbol-list
- (insert (format " %s = intern (\"" (car symbol-list)))
- (let ((start (point)))
- (insert (substring (car symbol-list) 1))
- (subst-char-in-region start (point) ?_ ?-))
- (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
- (setq symbol-list (cdr symbol-list)))))
-
- */
-
- /*&&& symbols declared here &&&*/
- #if 0
- Lisp_Object Qauto_raise;
- Lisp_Object Qauto_lower;
- #endif
- Lisp_Object Qbackground_color;
- #if 0
- Lisp_Object Qbar;
- #endif
- Lisp_Object Qborder_color;
- Lisp_Object Qborder_width;
- #if 0
- Lisp_Object Qbox;
- Lisp_Object Qcursor_color;
- Lisp_Object Qcursor_type;
- Lisp_Object Qfont;
- #endif
- Lisp_Object Qforeground_color;
- #if 0
- Lisp_Object Qgeometry;
- Lisp_Object Qicon_left;
- Lisp_Object Qicon_top;
- Lisp_Object Qicon_type;
- Lisp_Object Qinternal_border_width;
- #endif
- Lisp_Object Qleft;
- #if 0
- Lisp_Object Qmouse_color;
- Lisp_Object Qnone;
- Lisp_Object Qparent_id;
- Lisp_Object Qsuppress_icon;
- #endif
- Lisp_Object Qtop;
- #if 0
- Lisp_Object Qundefined_color;
- Lisp_Object Qvertical_scroll_bars;
- Lisp_Object Qvisibility;
- Lisp_Object Qwindow_id;
- #endif
- Lisp_Object Qamiga_frame_parameter;
- #if 0
- Lisp_Object Quser_position;
- Lisp_Object Quser_size;
- #endif
-
- /* The below are defined in frame.c. */
- extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
- extern Lisp_Object Qunsplittable, Qmenu_bar_lines;
-
- extern Lisp_Object Vwindow_system_version;
-
-
- /* Connect the frame-parameter names for X frames
- to the ways of passing the parameter values to the window system.
-
- The name of a parameter, as a Lisp symbol,
- has an `amiga-frame-parameter' property which is an integer in Lisp
- but can be interpreted as an `enum amiga_frame_parm' in C. */
-
- enum amiga_frame_parm
- {
- AMIGA_PARM_FOREGROUND_COLOR,
- AMIGA_PARM_BACKGROUND_COLOR,
- AMIGA_PARM_MOUSE_COLOR,
- AMIGA_PARM_CURSOR_COLOR,
- AMIGA_PARM_BORDER_COLOR,
- AMIGA_PARM_ICON_TYPE,
- AMIGA_PARM_FONT,
- AMIGA_PARM_BORDER_WIDTH,
- AMIGA_PARM_INTERNAL_BORDER_WIDTH,
- AMIGA_PARM_NAME,
- AMIGA_PARM_AUTORAISE,
- AMIGA_PARM_AUTOLOWER,
- AMIGA_PARM_VERT_SCROLL_BAR,
- AMIGA_PARM_VISIBILITY,
- AMIGA_PARM_MENU_BAR_LINES
- };
-
-
- struct amiga_frame_parm_table
- {
- char *name;
- void (*setter)( FRAME_PTR frame, Lisp_Object val, Lisp_Object oldval);
- };
-
- void amiga_set_foreground_color (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_background_color (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_mouse_color (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_cursor_color (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_border_color (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_cursor_type (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_icon_type (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_font (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_border_width (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_internal_border_width (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_explicitly_set_name (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_autoraise (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_autolower (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_vertical_scroll_bars (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void amiga_set_visibility (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
- void x_set_menu_bar_lines (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval);
-
- static struct amiga_frame_parm_table __far amiga_frame_parms[] =
- {
- "foreground-color", amiga_set_foreground_color,
- "background-color", amiga_set_background_color,
- "mouse-color", amiga_set_mouse_color,
- "cursor-color", amiga_set_cursor_color,
- "border-color", amiga_set_border_color,
- "cursor-type", amiga_set_cursor_type,
- "icon-type", amiga_set_icon_type,
- "font", amiga_set_font,
- "border-width", amiga_set_border_width,
- "internal-border-width", amiga_set_internal_border_width,
- "name", amiga_explicitly_set_name,
- "auto-raise", amiga_set_autoraise,
- "auto-lower", amiga_set_autolower,
- "vertical-scroll-bars", amiga_set_vertical_scroll_bars,
- "visibility", amiga_set_visibility,
- "menu-bar-lines", x_set_menu_bar_lines,
- };
-
- /* Attach the `amiga-frame-parameter' properties to
- the Lisp symbol names of parameters relevant to X. */
-
- init_amiga_parm_symbols ()
- {
- int i;
-
- for (i = 0; i < sizeof (amiga_frame_parms) / sizeof (amiga_frame_parms[0]); i++)
- Fput (intern (amiga_frame_parms[i].name), Qamiga_frame_parameter,
- make_number (i));
- }
-
- /* Change the parameters of FRAME as specified by ALIST.
- If a parameter is not specially recognized, do nothing;
- otherwise call the `amiga_set_...' function for that parameter. */
-
- void
- x_set_frame_parameters (f, alist) /* CHFIXME: fix references in window.c */
- FRAME_PTR f;
- Lisp_Object alist;
- {
- Lisp_Object tail;
-
- /* If both of these parameters are present, it's more efficient to
- set them both at once. So we wait until we've looked at the
- entire list before we set them. */
- Lisp_Object width, height;
-
- /* Same here. */
- Lisp_Object left, top;
-
- /* Record in these vectors all the parms specified. */
- Lisp_Object *parms;
- Lisp_Object *values;
- int i;
-
- i = 0;
- for (tail = alist; CONSP (tail); tail = Fcdr (tail))
- i++;
-
- parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
- values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
-
- /* Extract parm names and values into those vectors. */
-
- i = 0;
- for (tail = alist; CONSP (tail); tail = Fcdr (tail))
- {
- Lisp_Object elt, prop, val;
-
- elt = Fcar (tail);
- parms[i] = Fcar (elt);
- values[i] = Fcdr (elt);
- i++;
- }
-
- width = height = top = left = Qunbound;
-
- /* Now process them in reverse of specified order. */
- for (i--; i >= 0; i--)
- {
- Lisp_Object prop, val;
-
- prop = parms[i];
- val = values[i];
-
- if (EQ (prop, Qwidth))
- width = val;
- else if (EQ (prop, Qheight))
- height = val;
- else if (EQ (prop, Qtop))
- top = val;
- else if (EQ (prop, Qleft))
- left = val;
- else
- {
- register Lisp_Object param_index, old_value;
-
- param_index = Fget (prop, Qamiga_frame_parameter);
- old_value = get_frame_param (f, prop);
- store_frame_param (f, prop, val);
- if (XTYPE (param_index) == Lisp_Int
- && XINT (param_index) >= 0
- && (XINT (param_index)
- < sizeof (amiga_frame_parms)/sizeof (amiga_frame_parms[0])))
- (*amiga_frame_parms[XINT (param_index)].setter)(f, val, old_value);
- }
- }
-
- /* Don't die if just one of these was set. */
- if (EQ (left, Qunbound))
- XSET (left, Lisp_Int, EMACS_WIN(f)->LeftEdge);
- if (EQ (top, Qunbound))
- XSET (top, Lisp_Int, EMACS_WIN(f)->TopEdge);
-
- /* Don't die if just one of these was set. */
- if (EQ (width, Qunbound))
- XSET (width, Lisp_Int, FRAME_WIDTH (f));
- if (EQ (height, Qunbound))
- XSET (height, Lisp_Int, FRAME_HEIGHT (f));
-
- #if 0 /* CHFIXME */
- /* Don't set these parameters these unless they've been explicitly
- specified. The window might be mapped or resized while we're in
- this function, and we don't want to override that unless the lisp
- code has asked for it.
-
- Don't set these parameters unless they actually differ from the
- window's current parameters; the window may not actually exist
- yet. */
- {
- Lisp_Object frame;
-
- check_frame_size (f, &height, &width);
-
- XSET (frame, Lisp_Frame, f);
-
- if ((NUMBERP (width) && XINT (width) != FRAME_WIDTH (f))
- || (NUMBERP (height) && XINT (height) != FRAME_HEIGHT (f)))
- Fset_frame_size (frame, width, height);
- if ((NUMBERP (left) && XINT (left) != emacs_win->LeftEdge)
- || (NUMBERP (top) && XINT (top) != emacs_win->TopEdge))
- Fset_frame_position (frame, left, top);
- }
- #endif
- }
-
- /* Insert a description of internally-recorded parameters of frame X
- into the parameter alist *ALISTPTR that is to be given to the user.
- Only parameters that are specific to the X window system
- and whose values are not correctly recorded in the frame's
- param_alist need to be considered here. */
-
- x_report_frame_params (f, alistptr) /* CHFIXME: fix references in frame.c */
- FRAME_PTR f;
- Lisp_Object *alistptr;
- {
- char buf[16];
-
- store_in_alist (alistptr, Qleft, make_number (EMACS_WIN(f)->LeftEdge));
- store_in_alist (alistptr, Qtop, make_number (EMACS_WIN(f)->TopEdge));
- #if 0 /* CHFIXME: available on the AMIGA ! */
- store_in_alist (alistptr, Qborder_width,
- make_number (f->display.x->border_width));
- store_in_alist (alistptr, Qinternal_border_width,
- make_number (f->display.x->internal_border_width));
- sprintf (buf, "%d", FRAME_AMIGA_WINDOW (f));
- store_in_alist (alistptr, Qwindow_id,
- build_string (buf));
- FRAME_SAMPLE_VISIBILITY (f);
- store_in_alist (alistptr, Qvisibility,
- (FRAME_VISIBLE_P (f) ? Qt
- : FRAME_ICONIFIED_P (f) ? Qicon : Qnil));
- #endif
- }
-
- #define CHFIXMELINE() fprintf(stderr,"CHFIXME: %s %d\n", __FILE__, __LINE__)
-
- void amiga_set_foreground_color (FRAME_PTR f, Lisp_Object pen, Lisp_Object oldval)
- {
- int fg;
- extern int foreground; /* CHFIXME */
-
- check_intuition();
- CHECK_NUMBER(pen, 0);
-
- fg = XUINT (pen);
- if (pen > 7) error("Pen colors must be between 0 & 7");
- foreground = fg;
- reset_window(f);
- }
- void amiga_set_background_color (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_mouse_color (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_cursor_color (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_border_color (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_cursor_type (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_icon_type (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_font (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_border_width (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_internal_border_width (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_explicitly_set_name (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_autoraise (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_autolower (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_vertical_scroll_bars (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
- void amiga_set_visibility (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)
- {
- CHFIXMELINE();
- }
-
- void
- x_set_menu_bar_lines (FRAME_PTR f, Lisp_Object value, Lisp_Object oldval)/* CHFIXME: fix references in frame.c */
- {
- int nlines;
- int olines = FRAME_MENU_BAR_LINES (f);
-
- fprintf(stderr,"amiga_set_menu_bar_lines\n");
-
- /* Right now, menu bars don't work properly in minibuf-only frames;
- most of the commands try to apply themselves to the minibuffer
- frame itslef, and get an error because you can't switch buffers
- in or split the minibuffer window. */
- if (FRAME_MINIBUF_ONLY_P (f))
- return;
-
- if (XTYPE (value) == Lisp_Int)
- nlines = XINT (value);
- else
- nlines = 0;
-
- FRAME_MENU_BAR_LINES (f) = 0;
- fprintf(stderr,"\tnlines = %d\n", nlines);
- if (nlines)
- FRAME_EXTERNAL_MENU_BAR (f) = 1;
- else
- {
- #if 0 /* CHFIXME */
- if (FRAME_EXTERNAL_MENU_BAR (f) == 1)
- free_frame_menubar (f);
- #endif
- FRAME_EXTERNAL_MENU_BAR (f) = 0;
- #if 0
- f->display.x->menubar_widget = 0;
- #endif
- }
- }
-
- void syms_of_amiga_fns(void)
- {
- /* The section below is built by the lisp expression at the top of the file,
- just above where these variables are declared. */
- /*&&& init symbols here &&&*/
- #if 0
- Qauto_raise = intern ("auto-raise");
- staticpro (&Qauto_raise);
- Qauto_lower = intern ("auto-lower");
- staticpro (&Qauto_lower);
- #endif
- Qbackground_color = intern ("background-color");
- staticpro (&Qbackground_color);
- #if 0
- Qbar = intern ("bar");
- staticpro (&Qbar);
- #endif
- Qborder_color = intern ("border-color");
- staticpro (&Qborder_color);
- Qborder_width = intern ("border-width");
- staticpro (&Qborder_width);
- #if 0
- Qbox = intern ("box");
- staticpro (&Qbox);
- Qcursor_color = intern ("cursor-color");
- staticpro (&Qcursor_color);
- Qcursor_type = intern ("cursor-type");
- staticpro (&Qcursor_type);
- Qfont = intern ("font");
- staticpro (&Qfont);
- #endif
- Qforeground_color = intern ("foreground-color");
- staticpro (&Qforeground_color);
- #if 0
- Qgeometry = intern ("geometry");
- staticpro (&Qgeometry);
- Qicon_left = intern ("icon-left");
- staticpro (&Qicon_left);
- Qicon_top = intern ("icon-top");
- staticpro (&Qicon_top);
- Qicon_type = intern ("icon-type");
- staticpro (&Qicon_type);
- Qinternal_border_width = intern ("internal-border-width");
- staticpro (&Qinternal_border_width);
- #endif
- Qleft = intern ("left");
- staticpro (&Qleft);
- #if 0
- Qmouse_color = intern ("mouse-color");
- staticpro (&Qmouse_color);
- Qnone = intern ("none");
- staticpro (&Qnone);
- Qparent_id = intern ("parent-id");
- staticpro (&Qparent_id);
- Qsuppress_icon = intern ("suppress-icon");
- staticpro (&Qsuppress_icon);
- #endif
- Qtop = intern ("top");
- staticpro (&Qtop);
- #if 0
- Qundefined_color = intern ("undefined-color");
- staticpro (&Qundefined_color);
- Qvertical_scroll_bars = intern ("vertical-scroll-bars");
- staticpro (&Qvertical_scroll_bars);
- Qvisibility = intern ("visibility");
- staticpro (&Qvisibility);
- Qwindow_id = intern ("window-id");
- staticpro (&Qwindow_id);
- #endif
- Qamiga_frame_parameter = intern ("x-frame-parameter");
- staticpro (&Qamiga_frame_parameter);
- #if 0
- Quser_position = intern ("user-position");
- staticpro (&Quser_position);
- Quser_size = intern ("user-size");
- staticpro (&Quser_size);
- #endif
- /* This is the end of symbol initialization. */
-
- init_amiga_parm_symbols ();
- }
-
- void init_amiga_fns(void)
- {
- }
-